/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nattakute.model;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.codehaus.jackson.annotate.JsonBackReference;

/**
 *
 * @author simple7211
 */
@Entity
@Table(name = "complaint")
public class Complaint implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "complaintID")
    private Integer complaintId;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "title")
    private String title;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "description")
    private String description;
    
    @JsonBackReference
    @JoinColumn(name = "statusID", referencedColumnName = "statusID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Status status;
    
    @JsonBackReference
    @JoinColumn(name = "userID", referencedColumnName = "userID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Users user;
    
    @JsonBackReference
    @JoinColumn(name = "userSolve", referencedColumnName = "userID")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Users userSolve;

    public Complaint() {
    }

    public Complaint(Integer complaintId) {
        this.complaintId = complaintId;
    }

    public Complaint(Integer complaintId, String title, String description) {
        this.complaintId = complaintId;
        this.title = title;
        this.description = description;
    }

    

    public Integer getComplaintId() {
		return complaintId;
	}

	public void setComplaintId(Integer complaintId) {
		this.complaintId = complaintId;
	}

	public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Status getStatusID() {
        return status;
    }

    public void setStatusID(Status status) {
        this.status = status;
    }     
    
    
	
	public Users getUserSolve() {
		return userSolve;
	}

	public void setUserSolve(Users userSolve) {
		this.userSolve = userSolve;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}
	
	
	
	@Override
    public int hashCode() {
        int hash = 0;
        hash += (complaintId != null ? complaintId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Complaint)) {
            return false;
        }
        Complaint other = (Complaint) object;
        if ((this.complaintId == null && other.complaintId != null) || (this.complaintId != null && !this.complaintId.equals(other.complaintId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.da.model.Complaint[ complaintId=" + complaintId + " ]";
    }
    
}
